package eclipse.lib.graphics.primitives;
import javax.media.opengl.GL;
import eclipse.lib.graphics.shaders.*;
public class GLTriad extends GLObject 
{
	public GLTriad()
	{
		float verts[] = {-1f, 1f, 0f, 1f, -1f, 0f, -1f, -1f ,0f};
		setPolygonCount(1);
		addPolygon(new GLPolygon(3));
		setTriad(verts);
	}
	public void setTriad
	(
		float x1, float x2, float x3,
		float y1, float y2, float y3,
		float z1, float z2, float z3
	)
	{
		GLPolygon polygon = getPolygon();
		polygon.renderState = GL.GL_TRIANGLES;
		polygon.setPoint(0, x1, y1, z1);
		polygon.setPoint(1, x2, y2, z2);
		polygon.setPoint(2, x3, y3, z3);
	}
	public void setTriad(float verts[])
	{
		GLPolygon polygon = getPolygon();
		polygon.renderState = GL.GL_TRIANGLES;
		polygon.setPoint(0, verts[0], verts[1], verts[2]);
		polygon.setPoint(1, verts[3], verts[4], verts[5]);
		polygon.setPoint(2, verts[6], verts[7], verts[8]);
	}
	public GLPolygon getPolygon()
	{
		return getPolygon(0);
	}	
	public void setColor(GLColor color)
	{
		GLPolygon polygon = this.getPolygon();
		for(int i =0; i < 4; i++)
			polygon.setColor(i, color);
	}
	public void setColor(GLTriadShader color)
	{
		GLPolygon polygon = getPolygon();
		for(int i = 0; i < 3; i++)
			polygon.setColor(i, color.getColor(i));
	}
}
